package com.red.controller.admin;

import com.red.dto.HomePageQueryDTO;
import com.red.entity.Orders;
import com.red.result.PageResult;
import com.red.result.Result;
import com.red.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("/adminOrderController")
@RequestMapping("/admin/order")
@CrossOrigin
@Slf4j
public class OrderController {

    @Autowired
    private OrderService orderService;

    /**
     * 分页查询
     * @param dto
     * @return
     */
    @GetMapping
    public Result<PageResult> pageQuery(HomePageQueryDTO dto){
        log.info("分页查询信息 = {}",dto);
        PageResult pageResult = orderService.pageQuery(dto);
        return Result.success(pageResult);
    }

    @PostMapping("/update")
    public Result updateStatus(@RequestBody Orders orders){
        log.info("修改状态 = {}",orders);
        orderService.updateStatus(orders);
        return Result.success();
    }
}
